
import sys  
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout  
  
class SimpleApp(QWidget):  
    def __init__(self):  
        super().__init__()  
  
        self.initUI()  
  
    def initUI(self):  
        # 设置窗口的标题和大小  
        self.setWindowTitle('PyQt6 Simple App')  
        self.setGeometry(100, 100, 300, 200)  
  
        # 创建标签和按钮  
        self.label = QLabel('Hello, PyQt6!', self)  
        self.button = QPushButton('Click Me!', self)  
  
        # 设置按钮的点击事件  
        self.button.clicked.connect(self.changeLabelText)  
  
        # 创建垂直布局  
        layout = QVBoxLayout()  
        layout.addWidget(self.label)  
        layout.addWidget(self.button)  
  
        # 设置窗口的布局  
        self.setLayout(layout)  
  
    def changeLabelText(self):  
        # 点击按钮时改变标签的文本  
        self.label.setText('Button Clicked!')  
  
if __name__ == '__main__':  
    app = QApplication(sys.argv)  
    ex = SimpleApp()  
    ex.show()  
    sys.exit(app.exec())